package com.controller;

import com.thread.AccessTokenThread;
import com.util.WeixinUtil;
import net.sf.json.JSONObject;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/template")
public class TemplateController {

    private static Logger log = LoggerFactory.getLogger(TemplateController.class);
    @RequestMapping(value = "/test",method = RequestMethod.GET)
    public void t(){
        // 调用接口获取access_token
        String at = AccessTokenThread.accessToken.getToken();
        String url="https://api.weixin.qq.com/cgi-bin/template/api_set_industry?access_token="+at;
        String json=JSONObject.fromObject(test()).toString();
        JSONObject jsonObject= WeixinUtil.httpRequest(url,"POST",json);
        String result= String.valueOf(jsonObject);
        log.info(result);
    }
    public Map<String,String> test(){
        Map<String,String> map=new HashMap<String,String>();
        map.put("industry_id1","22");
        map.put("industry_id2","22");
        return map;
    }
}
